package QuanLyNhanSu;

import java.sql.*;
public class TestResultsetMetadata {
	static Conn c;
	public static void main(String[] a){
		c = new Conn("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\Hoc Tap\\Hoc Ki VII\\Chuyen De Java\\OnTap_Code\\OnTap\\src\\QuanLyNhanSu\\QLNhanSu.mdb;}", "", "");
			try {
				String sql = "SELECT * FROM NguoiDung";
				ResultSet rs = c.executeQ(sql);
				ResultSetMetaData rsMD = rs.getMetaData();
				//System.out.print(rsMD.getColumnCount() + ": ");
				String s = ", ";
				/*for (int i = 1; i <= rsMD.getColumnCount(); i ++){
					if (i == rsMD.getColumnCount())
						s = "";
					System.out.print(rsMD.getColumnName(i) + s);
				}
				System.out.println();
				for (int i = 1; i <= rsMD.getColumnCount(); i ++){
				int jdbcType = rsMD.getColumnType(i);
				   String name = rsMD.getColumnTypeName(i);
				   System.out.println("Column " + i + " is JDBC type " + 	jdbcType + ", which is JDBC type " + name);
				}
				System.out.println();
				System.out.println(rsMD.getColumnName(3));
				System.out.println(rsMD.getColumnTypeName(3));
				System.out.println(rsMD.getTableName(1));
				System.out.println(rsMD.isCurrency(1));
				System.out.println(rsMD.isReadOnly(1));*/
				while (rs.next()) {
				      // Get data at cursor
				      System.out.print(rs.getString(1)+"|");
				      System.out.print(rs.getString(2)+"|");
				      System.out.print(rs.getString(3)+"|");
				      System.out.print(rs.getString(4)+"|");
				      System.out.print(rs.getString(5)+"|\n");
				    }
			} catch (SQLException e) {
				e.printStackTrace();
			}
	}
}

